Ext.define('Holo.store.SpotDescriptions', {
    extend: 'Ext.data.Store',
    requires: 'Holo.model.SpotDescription',
    model: 'Holo.model.SpotDescription',
    
    constructor: function(cfg) {
        var me = this;
        cfg = cfg || {};
        me.callParent([Ext.apply({}, cfg)]);
    },
    
    listeners: {
        
        beforeload : function (store, operation, eOpts){
            
            //console.log(store.filters); 
            //try {
            //    //cancel load if the spot_id is 0 (mean this is a new spot)
            //    if(store.filters.items[0].value == 0){
            //        return false;
            //    }  
            //} catch(e) {
            //    alert(e);
            //}            
        },
        
        load : function(store, records, successful, operation, eOpts){
            
            //console.log('load store SpotDescriptions :' + successful);
        },
        
        add: function(store, records,  index,  eOpts){
            store.sync();
        },
    
        update: function(store, record, operation,  eOpts){
            store.sync();
        }
    },
    
    /**
     * ChecK if the codelang lang is all ready in the store
     * @param {String} the language code
     * @returns {boolean} true is the langue exist
     */
    langExist : function(codeLang){
        for (var i=0; i < this.count(); i++) {
	    if (this.getAt(i).get('language') == codeLang){
                return true;
            }
	}
        return false;
    },

    

});